package us.wili.dev.client.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import us.wili.dev.client.model.req.FabricReq;
import us.wili.dev.client.model.rsp.GoodsRsp;
import us.wili.dev.client.model.rsp.ShopcartRsp;
import us.wili.dev.client.model.rsp.ShowClothRsp;
import us.wili.dev.client.service.ClientGoodsService;
import us.wili.dev.common.model.Pager;
import us.wili.dev.common.model.PagerResponseDto;
import us.wili.dev.common.model.ResponseDto;
import us.wili.dev.common.util.ResponseUtil;

import javax.validation.Valid;
import java.util.List;

@Validated
@RestController
@RequestMapping("/api/fabric")
@Api(tags = "面料分类")
public class FabricController {
    @Autowired
    private ClientGoodsService clientGoodsService;

    @ApiOperation(value = "分类查询", nickname = "classfabric")
    @RequestMapping(value = "/classfabric", method = RequestMethod.GET)
    public PagerResponseDto<GoodsRsp> classfabric(@Valid FabricReq req) {
        Pager<GoodsRsp> search = clientGoodsService.classfabric(req);
        return new PagerResponseDto<>(search);
    }

    @ApiOperation(value = "布料展示", nickname = "ShowCloth")
    @RequestMapping(value = "/ShowCloth", method = RequestMethod.GET)
    public ResponseDto<ShowClothRsp> ShowCloth(){
        List<ShowClothRsp> rsp =clientGoodsService.ShowCloth();
        return ResponseUtil.getSuccessRsp(rsp);
    }

}
